import request from '@/api/request'
import { UserLoginPlayLoad } from '#/store'
import { ResponseFormat, ResponseFormatWithList, IPaginationFormWithCondition } from '#/http'

/**
 * @breif: 获取用户信息
 * @return {*}
 */
export const getUserInfo = () => {
  return request.get('/user/userInfo')
}

/**
 * @breif: 登录
 * @param {UserLoginPlayLoad} data
 * @return {*}
 */
export const Login = (data: UserLoginPlayLoad): Promise<ResponseFormat> => {
  return request.post('/login', data)
}

// 注册
export const regist = (data: UserLoginPlayLoad): Promise<ResponseFormat> => {
  return request.post('/user/regist', data)
}

// 创建用户
export const createUser = (data: UserLoginPlayLoad): Promise<ResponseFormat> => {
  return request.post('/user/create', data)
}

// 更新用户信息updateUser
export const updateUser = (data: UserLoginPlayLoad): Promise<ResponseFormat> => {
  return request.post('/user/update', data)
}
// 查询用户列表
export const queryUserListAPI = (data: IPaginationFormWithCondition): Promise<ResponseFormatWithList> => {
  return request.post('/user/list', data)
}

// 删除用户
export const delUserAPI = (id: string): Promise<ResponseFormat> => {
  return request.delete('/user/del', {
    params: {
      id
    }
  })
}
